package com.paziy.notes.core.notes;

/**
 * Lengths of notes.
 * @author thecederick@gmail.com (Paziy Evgeniy)
 * @version 0.2
 * @since 0.1 (27.11.13 10:43)
 */
public enum NoteValue {
    Whole((byte) 1, 1f), //whole notes length 4/4
    Minim((byte) 2, 0.5f),  //Half notes length 2/4
    Crotchet((byte) 4, 0.25f), //Quarter notes length 1/4
    Quaver((byte) 8, 0.125f), //Eight notes length 1/8
    Semiquaver((byte) 16, 0.0625f), //sixteenth notes length 1/16
    Demisemiquaver((byte) 32, 0.03125f), //thirty-second notes length 1/32
    Hemidemisemiquaver((byte) 64, 0.015625f); //sixty-fourth notes length 1/64

    private byte fraction;
    private float realFraction;

    NoteValue(byte fraction, float realFraction) {
        this.fraction = fraction;
        this.realFraction = realFraction;
    }

    /**
     * Getter for fraction. Returns byte value
     *
     * @return length of notes
     */
    public byte getFraction() {
        return fraction;
    }

    /**
     * Getter for realFraction. Returns float value
     *
     * @return length of notes
     */
    public float getRealFraction() {
        return realFraction;
    }

    /**
     * String representation of byte notes length
     *
     * @return length of notes
     */
    @Override
    public String toString() {
        return Byte.toString(fraction);
    }
}
